package programs.statement;

import java.util.HashSet;
import java.util.Set;

import game.Ship;
import programs.expression.implementedClasses.Variable;
import programs.expression.superClasses.Expression;

public class Print extends BasicStatement {
	
	private Expression expressionToPrint;

	public Print(Expression expressionToPrint) {
		this.expressionToPrint = expressionToPrint;
	}

	@Override
	public void execute() {
			System.out.println(expressionToPrint.getValue());
	}

	@Override
	public boolean isValidStatement() {
		return getExpressionToPrint().isValidExpression();
	}

	public Expression getExpressionToPrint() {
		return this.expressionToPrint;
	}

	@Override
	public boolean containsAction() {
		return false;
	}
	
	@Override
	public void setExecuter(Ship executer) {
		super.setExecuter(executer);
		getExpressionToPrint().setExecuter(executer);
	}
	
	@Override
	public void assignGlobalVariable(Variable variable) {
		expressionToPrint = expressionToPrint.assignGlobalVariable(variable);
	}

	@Override
	public Set<Variable> getVariables() {
		Set<Variable> set = new HashSet<Variable>();
		set.addAll(getExpressionToPrint().getVariables());
		return set;
	}
}
